home *** CD-ROM | disk | FTP | other *** search
/ Mastering Web Site Development / Microsoft Mastering Web Site Development (Microsoft) (1997).iso / Media / Ch05 / W05D030.cc2 < prev    next >
Encoding:
Text File  |  1997-04-24  |  1.7 KB  |  32 lines

  1. 0, In this demonstration you will learn how to create 
  2. 4, an initialization event for a Web page using 
  3. 7, Visual InterDev. Open the page you want to add the 
  4. 11, initialization script to with the Visual InterDev 
  5. 14, Source Editor. There are two places where you can add 
  6. 17, initialization code in a Web page. If you add 
  7. 21, code in a script section that is not included inside 
  8. 25, of a procedure it will run when the browser 
  9. 27, reaches that section as it is reading the file. For 
  10. 31, example, this code sets a variable and then calls 
  11. 34, msgbox to output the value of the variable. The second 
  12. 39, place you can add initialization code to is the 
  13. 42, OnLoad event of the Window object. So, in the 
  14. 46, script section I can create an event procedure named 
  15. 49, "window_onload." In the event procedure I can add 
  16. 60, any VBScript code I want. For example, I can declare 
  17. 64, another variable "y," assign it a value, and use 
  18. 71, msgbox to output it. Any code inside the 
  19. 78, window_onload event procedure will run after the browser is 
  20. 83, done loading the page and therefore after any 
  21. 86, other initialization code included in the script 
  22. 89, section, but not included in a procedure. Let's save 
  23. 93, this file and view it with the Visual InterDev 
  24. 96, browser. Notice that the message box from the 
  25. 104, initialization code in the script section displays first, 
  26. 108, displaying the value of 5. When I dismiss the 
  27. 110, message box the message box from the window_onload 
  28. 114, event runs at the same time that the page is loaded, 
  29. 117, displaying the value of "hi." So, now you know how 
  30. 122, to add initialization code to a Web page using 
  31. 125, the window_onload event.
  32. 127, END